﻿namespace KMT_Pro.ViewModels
{
    using System;
    using System.ComponentModel;
    using System.ServiceModel.DomainServices.Client;
    using System.Collections;

    public class MessageSendableViewModel : INotifyPropertyChanged
    {
        private bool isBusy = false;

        public MessageSendableViewModel()
        {
        }

        #region INotifyPropertyChanged Members

        public event PropertyChangedEventHandler PropertyChanged;

        protected void OnPropertyChanged(string propertyName)
        {
            if (PropertyChanged != null)
                PropertyChanged(this, new PropertyChangedEventArgs(propertyName));
        }

        public bool IsBusy
        {
            set
            {
                this.isBusy = value;
                this.OnPropertyChanged("IsBusy");
            }

            get
            {
                return isBusy;
            }

        }

        /// <summary>
        /// 웹서비스 호출부분
        /// </summary>
        /// <param name="even"></param>
        /// <param name="EH"></param>
        public void ServerRun(LoadOperation even, EventHandler EH)
        {
            try
            {
                this.IsBusy = true;
                even.Completed += EH;
                even.Completed += (s, e) =>
                {
                    this.IsBusy = false;
                };
            }
            catch (Exception)
            {
                this.IsBusy = false;
            }
        }
        #endregion
    }
}
